using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using FireStarterModeller.UI;
using Habanero.Base;
using Habanero.Faces.Base;
using TreeViewController=Habanero.Faces.Base.TreeViewController;

namespace Firestarter.DB.Schema.UI
{
    public class FilteredTreeViewController : TreeViewController
    {
        private Predicate<IBusinessObject> _currentFilterPredicate;

        public FilteredTreeViewController(ITreeView treeView)
            : base(treeView)
        {

        }

        public void ApplyFilter(Predicate<IBusinessObject> predicate)
        {
            _currentFilterPredicate = predicate;
            foreach (KeyValuePair<IBusinessObject, NodeState> pair in ObjectNodes)
            {
                IBusinessObject businessObject = pair.Key;
                SetVisibility(businessObject, predicate(businessObject));
            }
        }
    }
}
